;;Testes automaticos


(define test
  (lambda (name proc args expected)
    (let ((result (apply proc args)))
      (list name
	    (equal? result expected)
	    result
	    expected))))

(define movement*
  (lambda (s0 v0 a t)
    (let ((s (+ s0
		(* v0 t)
		(/ (* a t t)
		   2))))
      2)))

(define movement
  (lambda (s0 v0 a t)
    (let ((s (+ s0
		(* v0 t)
		(/ (* a t t)
		   2))))
      s)))

(define tests (list (list "movement*" movement* '(1 1 1.5 2) 6.0)
		    (list "movement" movement '(1 1 1.5 2) 6.0)))

(define run-tests
  (lambda (tests)
    (map (lambda (l)
	   (apply test l))
	 tests)))

(define test-data (run-tests tests))

(define test-stats
  (lambda (test-results)
    (let next ((lst test-results)
	       (passed 0)
	       (failed 0))
      (cond ((null? lst)
	     (list passed failed))
	    ((cadar lst)
	     (next (cdr lst) (+ passed 1) failed))
	    (else
	     (next (cdr lst) passed (+ failed 1)))))))

(test-stats test-data)

;;Demonstração de corretude por indução


